<template>
    <view class="container">
        <!-- 导航栏 -->
        <view class="nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
            <view class="nav-back" @click="goBack">←</view>
            <view class="nav-title">预约成功</view>
            <view class="nav-actions">···</view>
        </view>
        
        <!-- 成功内容 -->
        <view class="success-content">
            <view class="success-icon">
                <view class="check-circle">
                    <text class="check">✓</text>
                </view>
            </view>
            
            <view class="success-text">预约成功</view>
            
            <view class="order-info">
                <view class="order-label">预约编号:</view>
                <view class="order-number">{{ orderNumber }}</view>
            </view>
            
            <view class="action-buttons">
                <view class="btn-primary" @click="goToHome">返回首页</view>
                <view class="btn-secondary" @click="goToDetail">预约详情</view>
            </view>
        </view>
    </view>
</template>

<script setup>
import { ref, onMounted } from 'vue';

// 响应式数据
const orderNumber = ref('324252536363634');
const statusBarHeight = ref(0);

// 方法定义
function goBack() {
    uni.navigateBack();
}

function goToHome() {
    // 返回首页
    uni.switchTab({
        url: '/pages/index/index'
    });
}

function goToDetail() {
    // 跳转到预约详情页面
    uni.navigateTo({
        url: '../bookingDetail/bookingDetail'
    });
}

onMounted(() => {
    // 获取状态栏高度，使用推荐的wx.getWindowInfo API
    try {
        const windowInfo = uni.getWindowInfo();
        statusBarHeight.value = windowInfo.statusBarHeight;
    } catch (error) {
        console.error('获取窗口信息失败:', error);
        statusBarHeight.value = 0;
    }
});
</script>

<style>
.container {
    background-color: #f5f5f5;
    min-height: 100vh;
}

.nav-bar {
    height: 88rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1E88E5;
    color: white;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-back {
    font-size: 20px;
}

.nav-title {
    font-size: 18px;
    font-weight: bold;
}

.success-content {
    background-color: white;
    margin: 20px 16px;
    padding: 40px 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.success-icon {
    margin-bottom: 20px;
}

.check-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: #1E88E5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.check {
    color: white;
    font-size: 48px;
    font-weight: bold;
}

.success-text {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 30px;
    color: #333;
}

.order-info {
    margin-bottom: 40px;
    text-align: center;
}

.order-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.order-number {
    font-size: 16px;
    color: #333;
    font-weight: bold;
    letter-spacing: 1px;
}

.action-buttons {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn-primary {
    padding: 15px;
    background-color: #1E88E5;
    color: white;
    text-align: center;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
}

.btn-secondary {
    padding: 15px;
    background-color: #e0e0e0;
    color: #666;
    text-align: center;
    border-radius: 8px;
    font-size: 16px;
}
</style>